import App from '../App.vue';

// Webpack将相同chunk下的所有异步模块打包到一个异步块里面 —— 这也意味着我们无须明确列出 require.ensure 的依赖（传空数组就行）
// [] 依赖的模块数组 ()=> 回调函数  'home'构建生成文件命名时使用
const home = r => require.ensure([],() => r(require('../page/home/home')), 'home');
const login = r => require.ensure([], () => r(require('../page/login/login')), 'login');
const profile = r => require.ensure([],() => r(require('../page/profile/profile')), 'profile');
const info = r => require.ensure([],() => r(require('../page/profile/children/info')), 'info');
const city = r => require.ensure([],() => r(require('../page/city/city')), 'city');
const forget = r => require.ensure([],() => r(require('../page/forget/forget')), 'forget');
const msite = r => require.ensure([],() => r(require('../page/msite/msite')), 'msite');
const balance = r => require.ensure([],() => r(require('../page/balance/balance')), 'balance');
const balanceDetail = r => require.ensure([],() => r(require('../page/balance/chidlren/detail')), 'balanceDetail');
const benefit = r => require.ensure([],() => r(require('../page/benefit/benefit')), 'benefit');
const hbDescription = r => require.ensure([],() => r(require('../page/benefit/children/hbDescription')), 'hbDescription');
const hbHistory = r => require.ensure([],() => r(require('../page/benefit/children/hbHistory')), 'hbHistory');
const commend = r => require.ensure([],() => r(require('../page/benefit/children/commend')), 'commend');
const coupon = r => require.ensure([],() => r(require('../page/benefit/children/coupon')), 'coupon');
const exchange = r => require.ensure([],() => r(require('../page/benefit/children/exchange')), 'exchange');
const points = r => require.ensure([],() => r(require('../page/points/points')), 'points');
const order = r => require.ensure([],() => r(require('../page/order/order')), 'order');
const vipcard = r => require.ensure([],() => r(require('../page/vipcard/vipcard')), 'vipcard');
const vipDescription = r => require.ensure([],() => r(require('../page/vipcard/children/vipDescription')), 'vipDescription');
const invoiceRecord = r => require.ensure([],() => r(require('../page/vipcard/children/invoiceRecord')), 'invoiceRecord');
const useCart = r => require.ensure([],() => r(require('../page/vipcard/children/useCart')), 'useCart');
const confirmOrder = r => require.ensure([],() => r(require('../page/confirmOrder/confirmOrder')), 'confirmOrder');
const chooseAddress = r => require.ensure([],() => r(require('../page/confirmOrder/children/chooseAddress')), 'chooseAddress');
const addAddress = r => require.ensure([],() => r(require('../page/confirmOrder/children/children/addAddress')), 'addAddress');
const searchAddress = r => require.ensure([],() => r(require('../page/confirmOrder/children/children/children/searchAddress')), 'searchAddress');
const payment = r => require.ensure([],() => r(require('../page/confirmOrder/children/payment')), 'payment');
const invoice = r => require.ensure([],() => r(require('../page/confirmOrder/children/invoice')), 'invoice');
const remark = r => require.ensure([],() => r(require('../page/confirmOrder/children/remark')), 'remark');
const userValidation = r => require.ensure([],() => r(require('../page/confirmOrder/children/userValidation')), 'userValidation');
const service = r => require.ensure([],() => r(require('../page/service/service')), 'service');
const questionDetail = r => require.ensure([],() => r(require('../page/service/children/questionDetail')), 'questionDetail');
const download = r => require.ensure([],() => r(require('../page/download/download')), 'download');
const search = r => require.ensure([],() => r(require('../page/search/search')), 'search');
const shop = r => require.ensure([],() => r(require('../page/shop/shop')), 'shop');
const foodDetail = r => require.ensure([],() => r(require('../page/shop/children/foodDetail')), 'foodDetail');
const shopDetail = r => require.ensure([],() => r(require('../page/shop/children/shopDetail')), 'shopDetail');
const shopSafe = r => require.ensure([],() => r(require('../page/shop/children/children/shopSafe')), 'shopSafe');
const food = r => require.ensure([],() => r(require('../page/food/food')), 'food');

export default [{
	path: '/',
	component: App,		// 顶层路由 对应index.html
	children: [			// 二级路由
		{ path: '', redirect: '/home'},
		{ path: '/home', component: home},	// 首页城市列表profile
		// 登录注册
		{ path: '/login', component: login},		
		// 修改密码
		{ path: '/forget', component: forget},
		// 个人信息
		{ path: '/profile', component: profile,
			children: [{ path: 'info',component: info}]
		},
		{ path: '/city/:cityid', component: city},
		// 所有商铺列表页  [缓存]
		{ path: '/msite', component: msite, meta: {keepAlive: true}},
		// 余额
		{ path: 'balance', component: balance,
			children: [{ path: 'detail', component: balanceDetail}]
		},
		// 我的优惠券
		{ path: 'benefit', component: benefit,
			children: [{
				path: 'hbDescription',component: hbDescription		// 红包说明
			},{
				path: 'hbHistory', component: hbHistory				// 历史红包
			},{
				path: 'coupon', component: coupon 					// 代金券说明
			},{
				path: 'exchange', component: exchange				// 兑换红包
			},{
				path: 'commend', component: commend					// 推荐有奖
			}]
		},
		// 我的积分页
		{ path: 'points', component: points},
		// 订单列表页
		{ path: '/order', compont: order},
		// vip卡片
		{ path: '/vipcard', component: vipcard,
			children: [{
				path: 'vipDescription',								// 会员说明
				component: vipDescription
			},{
				path: 'useCart',									// 购买会员卡
				component: useCart,
			},{
				path: 'invoiceRecord',								// 开发票
				component: invoiceRecord
			}]
		},
		// 服务中心
		{ path: '/service', component: service,						// 订单详情
			children: [{ path: 'questionDetail',component: questionDetail}]
		},
		// 下载页
		{ path: '/download', component: download},
		// 搜索页
		{ path: '/search/:geohash', component: search},
		// 订单确定页
		{ path: '/confirmOrder', component: confirmOrder,
			children: [{
				path: 'payment',			// 付款页
				component: payment,
			},{								// 发票抬头
				path: 'invoice',	
				component: invoice
			},
			{
				path: 'userValidation', 	// 用户验证
				component: userValidation
			},
			{								// 订单备注
				path: 'remark',	
				component: remark
			},{
				path: 'chooseAddress', 		// 选择地址
				component: chooseAddress,
				children: [{
					path: 'addAddress', 	// 添加地址
					component: addAddress,
					children: [{
						path: 'searchAddress', // 搜索地址
						component: searchAddress
					}]
				}]
			}]
		},
		// 商铺详情页
		{ path: '/shop', component: shop,
			children: [{
				path: 'foodDetail',			// 食品详情页
				component: foodDetail
			},{
				path: 'shopDetail',			// 商铺详情页
				component: shopDetail,
				children: [{
					path: 'shopSafe', 	    // 商铺安全认证页
					component: shopSafe
				}]	
			}]},
		// 商铺列表
		{ path: '/food', component: food},

	]

}]